import { observer } from "mobx-react";
import { WeaSearchGroup, WeaFormItem } from 'ecCom';
import { WeaSwitch } from 'comsMobx';
@observer
export default class Condition extends React.Component {
    render() {
        const { store } = this.props;
        const { conditionForm: form, conditions } = store;
        if (form && form.isFormInit) {
            const formParams = form.getFormParams(); // 获取表单的值
            return conditions.map((c, i) => {
                const items = c.items.map((field, index) => {
                    return {
                        com: (<WeaFormItem ecId={`${this && this.props && this.props.ecId || ''}_WeaFormItem@0wf4i2@${index}`}
                            label={`${field.label}`}
                            labelCol={{ span: field.labelcol }}
                            wrapperCol={{ span: field.fieldcol }}>
                            <WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@6kfycu@${index}`}
                                fieldConfig={field}
                                form={form}
                                formParams={formParams}
                            />
                        </WeaFormItem>),
                        colSpan: 1,
                        hide:field.hide
                    };
                });
                return (
                    <WeaSearchGroup ecId={`${this && this.props && this.props.ecId || ''}_WeaSearchGroup@h5vj0y@${i}`} needTigger={true} title={c.title} showGroup={c.defaultshow} items={items} />
                )
            });
        }
        return null;
    }
}